import type { AuthApi } from '#/api/core/model/userModel'

import { requestClient } from '#/api/request'

/**
 * 获取用户信息
 */
export async function getUserInfoApi() {
    const res = await requestClient.get<AuthApi.GetUserInfoModelOrgin>('/index/getUserInfo')

    return {
        ...res,
        roles: res.roles.map((item) => item.code),
        rolesVo: res.roles
    } as AuthApi.GetUserInfoModel
}

export async function fetchUpdatePwd(params: { newPassword: string; oldPassword: string }) {
    return await requestClient.put<AuthApi.GetUserInfoModelOrgin>('/index/updatePwd', params)
}
